﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SpyTxT
{
    /*
     * 运行状态机 
     * 
     */
    public interface IState
    {
        void Run();
    }
    public class StateManager
    {
        public enum STATE_MODE
        {
            STATE_IDLE,
            STATE_CHECK_NET,
            STATE_LOGIN_TICKET,
            STATE_LOGIN_UPDATA,
        }
        private Dictionary<STATE_MODE, IState> statemap = new Dictionary<STATE_MODE, IState>();
        private STATE_MODE curstate{get;set;}
        public void RunState()
        {
            if (statemap.ContainsKey(curstate))
            {
                statemap[curstate].Run();

               
            }
        }
        public void AddStateImp(STATE_MODE state,IState stateimp)
        {
            if (!statemap.ContainsKey(state))
            {
                statemap.Add(state, stateimp);
            }
        }
        public void SetState(STATE_MODE state)
        {
            this.curstate = state;
        }


    }
}
